/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package testing;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import oracle.jdbc.pool.OracleDataSource;

/**
 *
 * @author Asus
 */
public class CreateTableOracle {

    public static void main(String[] args) {
        String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:xe";
        String userid = "HR"; // gantikan dengan username anda
        String password = "elsa"; // gantikan dengan password anda

        Connection conn;
        try {
            OracleDataSource ds;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi is OK");
            Statement statement = conn.createStatement();

            String sql = " CREATE table MAHASISWA ( NAMA VARCHAR2(100) NOT NULL,"
                    + "NIM VARCHAR2(20) NOT NULL, "
                    + "NOMOR_EMAIL VARCHAR2(100) NOT NULL,"
                    + "PRODI VARCHAR2(100) NOT NULL,PERIODE VARCHAR2(20) NOT NULL,"
                    + "HARI VARCHAR2(20) NOT NULL,"
                    + "TANGGAL VARCHAR2(20) NOT NULL,"
                    + "DAFTAR_NILAI VARCHAR2 (20) NOT NULL,NASKAH_TA VARCHAR2 (20) NOT NULL,"
                    + "BEBASPINJAM_LAB VARCHAR2 (20) NOT NULL,BEBASPINJAM_DOSEN VARCHAR2 (20) NOT NULL,"
                    + "KP VARCHAR2 (20) NOT NULL,TOEFL VARCHAR2 (20) NOT NULL,"
                    + "TA VARCHAR2 (20) NOT NULL,SISTEM_POIN VARCHAR2 (20) NOT NULL,"
                    + "RBM VARCHAR2 (20) NOT NULL,"
                    + "constraint MAHASISWA_PK primary key (NIM) ENABLE)";

            statement.executeUpdate(sql);

        } catch (SQLException e) {
// perform error handling here
            System.out.println("error :" + e.getMessage());
        }
    }
}
